package com.lyq.event;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * 用户事件监听
 */
@Slf4j
@Component
public class UserMonitor {

//    @Async("lazyTraceExecutor")
    @EventListener(UserActionEvent.class)
    public void addUser(UserActionEvent event) {
        log.info("监听到用户事件:{}, currentThread:{}", event, Thread.currentThread());
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        log.info("监听到用户事件结束:{}, currentThread:{}", event, Thread.currentThread());
    }
}
